<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>行业动态详情 - 测盟汇系统</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <style>
        :root {
            --primary-color: #2c5545;
            --primary-light: #3a7d62;
            --primary-hover: #1e4636;
            --text-color: #333;
            --text-light: #555;
            --border-color: #d1d9d6;
            --bg-light: #f5f7f6;
            --bg-page: #e8ecea;
            --white: #fff;
            --shadow: 0 4px 24px rgba(44, 85, 69, 0.1);
            --radius: 8px;
            --transition: all 0.3s ease;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background: var(--bg-page);
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            color: var(--text-color);
            line-height: 1.6;
            padding: 20px;
        }

        .container {
            max-width: 900px;
            margin: 0 auto;
            background: var(--white);
            padding: 2rem;
            border-radius: var(--radius);
            box-shadow: var(--shadow);
        }

        h1 {
            color: var(--primary-color);
            margin-bottom: 1.5rem;
            display: flex;
            align-items: center;
        }

        h1 i {
            margin-right: 0.8rem;
        }

        .btn {
            padding: 0.8rem 1.5rem;
            border-radius: var(--radius);
            border: none;
            cursor: pointer;
            font-weight: 500;
            transition: var(--transition);
            display: inline-flex;
            align-items: center;
        }

        .btn i {
            margin-right: 0.5rem;
        }

        .btn-secondary {
            background: var(--bg-light);
            color: var(--text-color);
            border: 1px solid var(--border-color);
        }

        .btn-secondary:hover {
            background: #e1e8e4;
            transform: translateY(-2px);
        }

        .action-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 2rem;
            padding-bottom: 1rem;
            border-bottom: 1px solid var(--border-color);
        }

        .article-header {
            margin-bottom: 2rem;
        }

        .article-cover {
            width: 100%;
            max-height: 400px;
            object-fit: cover;
            border-radius: var(--radius);
            margin-bottom: 1.5rem;
            box-shadow: var(--shadow);
        }

        .article-title {
            font-size: 1.8rem;
            font-weight: 600;
            color: var(--primary-color);
            margin-bottom: 1rem;
        }

        .article-meta {
            display: flex;
            gap: 1.5rem;
            margin-bottom: 1.5rem;
            color: var(--text-light);
        }

        .article-meta-item {
            display: flex;
            align-items: center;
        }

        .article-meta-item i {
            margin-right: 0.5rem;
        }

        .article-intro {
            font-size: 1.1rem;
            line-height: 1.6;
            color: var(--text-color);
            background: var(--bg-light);
            padding: 1rem;
            border-radius: var(--radius);
            margin-bottom: 1.5rem;
            border-left: 4px solid var(--primary-color);
        }

        .article-content {
            line-height: 1.8;
        }

        .article-content img {
            max-width: 100%;
            height: auto;
            border-radius: var(--radius);
            margin: 1rem 0;
            box-shadow: var(--shadow);
        }

        @media (max-width: 768px) {
            .container {
                padding: 1.5rem;
            }

            .article-meta {
                flex-direction: column;
                gap: 0.5rem;
            }

            .article-title {
                font-size: 1.5rem;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <div class="action-bar">
        <h1>
            <i class="fas fa-newspaper"></i>
            行业动态详情
        </h1>
        <a href="/dynamic_list" class="btn btn-secondary">
            <i class="fas fa-arrow-left"></i> 返回列表
        </a>
    </div>

    <div id="dynamicDetail" class="article-detail">
        <!-- 内容将通过JavaScript动态加载 -->
    </div>
</div>

<script>
    function getUrlParam(name) {
        const reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        const r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURIComponent(r[2]);
        return null;
    }

    function formatDate(dateStr) {
        if (!dateStr) return '未知时间';
        const date = new Date(dateStr);
        return date.toLocaleString('zh-CN', {
            year: 'numeric',
            month: '2-digit',
            day: '2-digit',
            hour: '2-digit',
            minute: '2-digit'
        });
    }

    function loadDynamicDetail() {
        const id = getUrlParam('id');
        if (id) {
            $.ajax({
                url: '/dynamic/detail',
                method: 'GET',
                data: {
                    id: id
                },
                success: function(response) {
                    if (response.code === 200) {
                        const dynamic = response.data;
                        const publishTime = formatDate(dynamic.publishTime);
                        const html = `
                            <div class="article-header">
                                ${dynamic.coverUrl ? `<img src="${dynamic.coverUrl}" class="article-cover" alt="封面图片">` : ''}
                                <h2 class="article-title">${dynamic.title}</h2>
                                <div class="article-meta">
                                    <div class="article-meta-item">
                                        <i class="fas fa-user"></i>
                                        <span>${dynamic.author || '未知作者'}</span>
                                    </div>
                                    <div class="article-meta-item">
                                        <i class="fas fa-clock"></i>
                                        <span>${publishTime}</span>
                                    </div>
                                </div>
                                ${dynamic.introduction ? `<div class="article-intro">${dynamic.introduction}</div>` : ''}
                            </div>
                            <div class="article-content">
                                ${dynamic.content}
                            </div>
                        `;
                        $('#dynamicDetail').html(html);
                    } else {
                        alert(response.message);
                    }
                },
                error: function() {
                    alert('查询失败');
                }
            });
        }
    }

    $(document).ready(function() {
        loadDynamicDetail();
    });
</script>
</body>
</html>